<?php
include('lib/db_connection.php');
$emp = $_GET["emp"];
$company_id = $_SESSION['company_id'];

//$company_id = 1;
//$emp = 4;

$result_comp = mysql_query("SELECT * FROM company_tbl WHERE company_id='".$company_id."'")
or die("SELECT COMPANY ".mysql_error());
$row_comp = mysql_fetch_array($result_comp);

$query_emp = "SELECT * FROM employee_tbl WHERE autoid='".$emp."'";
$result_emp = mysql_query($query_emp) or die("SELECT EMP ".mysql_error());
$row_emp = mysql_fetch_array($result_emp);

function commafy($_)
       {
        return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,' , strrev( $_ ) ) );
       }
?>
<html>
<head>
</head>
<body style='background-color:#FFFFFF' onLoad='window.print()'>
<table border='0' width='810' style='margin-left:auto;margin-right:auto'>
<tr>
 <th width='100%' style='text-align:center;' colspan='3'><?php echo $row_comp['company_name']?></th>
</tr>
<tr>
 <th width='100%' style='text-align:center;' colspan='3'><?php echo $row_comp['address']?></th>
</tr>
<tr>
 <td width='33%' style='text-align:left;'>Contact No:<?php echo $row_comp['contact_no']?></td>
 <td width='34%' style='text-align:center;'><?php echo $row_comp['website']?></td>
 <td width='33%' style='text-align:right;'>Fax No:<?php echo $row_comp['fax_no']?></td>
</tr>
</table>
<div style="width: 100%; text-align: center;"><img border="0" src="image/emp_fuel_list.png" width="810" height="30" /></div>
	
<table id='veh_info' border='0' width='810' style='margin-left:auto;margin-right:auto'>
  <tr>
    <td><b>Name:&nbsp;<?php echo $row_emp['lname']?>,<?php echo $row_emp['fname']?></b></td>
  </tr>
  <tr>
    <td><b>Job Title:&nbsp;<?php echo $row_emp['job_title']?></b></td>
  </tr>
</table>
	
	
<table border='1' width='810' style='margin-left:auto;margin-right:auto'>
<tr>
	<th style='width:16%'>Date</th>
	<th style='width:16%'>Vehicle</th>
	<th style='width:17%'>Brand</th>
	<th style='width:17%'>Liters</th>
	<th style='width:17%'>Price/Liter</th>
	<th style='width:17%'>Total</th>
</tr>
<?php
$query_list = "SELECT * FROM emp_fuel_tbl WHERE company_id='".$company_id."' and emp_id='".$emp."'";
$result_list = mysql_query($query_list) or die("LIST ".mysql_error());
while($row_list = mysql_fetch_array($result_list))
{
?>
<tr>
	<td style='text-align:center'><?php echo $row_list['date']?></td>
	<td style='text-align:center'><?php echo $row_list['plate']?></td>
	<td style='text-align:center'><?php echo $row_list['brand']?></td>
	<td style='text-align:right'><?php echo $row_list['gallons']?></td>
	<td style='text-align:right'><?php echo $row_list['price']?></td>
	<td style='text-align:right'><?php echo $row_list['tot_cost']?></td>
</tr>
<?php
}
?>
</table>
<p style=" position: relative; bottom: 0; left: 0; width: 100%; text-align: center;"><img border="0" src="image/footer_wo.png" width="135" height="30" style='margin-left:auto;margin-right:auto'/></p>
</body>
</html>